﻿using AutoMapper;

namespace AbpZeroTemplate.Api.App
{
    public static class CustomAutoMapper
    {
        private static volatile bool _mappedBefore;
        private static readonly object SyncObj = new object();
        /// <summary>
        /// </summary>
        public static void CreateMappings(IMapperConfigurationExpression configuration)
        {
            lock (SyncObj)
            {
                if (_mappedBefore)
                {
                    return;
                }

                CreateMappingsInternal(configuration);

                _mappedBefore = true;
            }
        }

        private static void CreateMappingsInternal(IMapperConfigurationExpression configuration)
        {
            //获取出价数据
            //configuration.CreateMap<GetProductBiddingInputDto, GetProductBiddingInput>()
            //    .ForMember(t => t.MaxResultCount, o => o.MapFrom(s => s.PageSize))
            //    .ForMember(t => t.SkipCount, o => o.MapFrom(s => (s.Page - 1) * s.PageSize))
            //    .ForMember(t => t.Validable, o => o.UseValue(true))
            //    .ForMember(t => t.BiddingStatus, o => o.UseValue((int)ProductBiddingStatus.Paid));


            ////注册实体-->UserEditDto
            //configuration.CreateMap<RegisterInputDto, UserEditDto>()
            //    .ForMember(t => t.IsActive, o => o.UseValue(true));

            ////注册用户
            //configuration.CreateMap<RegisterInputDto, CreateOrUpdateUserInput>()
            //    .ForMember(t => t.SetRandomPassword, o => o.UseValue(false))
            //    .ForMember(t => t.SendActivationEmail, o => o.UseValue(false))
            //    //.ForMember(t => t.User.PhoneNumber, o => o.MapFrom(s => s.PhoneNumber))
            //    //.ForMember(t => t.User.Password, o => o.MapFrom(s => s.Password))
            //    .ForMember(t => t.AssignedRoleNames, o => o.UseValue(new string[] { }));
        }
    }
}
